﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq;

namespace DB
{
    public class DCFactory
    {
        public static T GetDataContext<T>() where T : DataContext, new()
        {
            HttpContext context = HttpContext.Current;
            string key = typeof(T).ToString();
            T dc = context.Items[key] as T;

            if (dc == null)
            {
                dc = new T();
                context.Items[key] = dc;
            }

            return dc;
        }
    }
}